#include <stdio.h>
#define ASIZE 1337

int main ()
{
	int arr[ASIZE], n, i=0, j;

	freopen("symmetric.in", "r", stdin);
	freopen("symmetric.out", "w", stdout);

	scanf("%d", &n);
	while (scanf("%d", &arr[i]) == 1 && i++ < n);
	if (n % 2) { //odd
		i = (n - 1) / 2 - 1; //middle -1
		j = i + 2; //middle +1
		while (i >= 0) {
			if (arr[i] != arr[j]) {
				printf("NO\n");
				return 0;
			} else {
				i--;
				j++;
			}
		}
	} else {
		i = n / 2 - 1; //left mid
		j = i + 1;
		while (i >= 0) {
			if (arr[i] != arr[j]) {
				printf("NO\n");
				return 0;
			} else {
				i--;
				j++;
			}
		}
	}
	printf("YES\n");
	return 0;
}
